import "package:flutter/material.dart";
import "./RecommendItemUPInfo.dart";
import "./RecommendItemContent.dart"; //通用
import "package:myapp/_pages/video.dart";

// 视频类型推荐的视频类
class RecommendItemVideoItem {
  String coverUrl; //封面图
  String playCount; //播放量
  String danmuCount; //弹幕量
  String videoDuration; //视频时长
  String title; //视频标题
  String likeCount; //点赞量
  bool isPromotion; //是否推广
  bool isVerticalScreen; //是否竖屏
  bool isHotLike; //是否近期热门
  RecommendItemVideoItem({
    required this.coverUrl,
    required this.playCount,
    required this.danmuCount,
    required this.videoDuration,
    required this.title,
    required this.likeCount,
    required this.isVerticalScreen,
    this.isPromotion = false,
    this.isHotLike = false,
  });
}

// 视频类型
class RecommendItemVideoItemWidget extends StatelessWidget {
  final RecommendItemVideoItem recommendItemVideoItem;
  final RecommendItemUPInfo? recommendItemUPInfo;
  const RecommendItemVideoItemWidget({
    super.key,
    required this.recommendItemVideoItem,
    this.recommendItemUPInfo,
  });
  @override
  Widget build(BuildContext context) {
    TextStyle textStyle = const TextStyle(
      fontSize: 10,
      color: Colors.white,
    );

    return RecommendItemContentWidget(
      onTap: () {
        Navigator.pushNamed(context, "/video",
            arguments:
                Arguments(recommendItemVideoItem: recommendItemVideoItem));
      },
      imageUrl: recommendItemVideoItem.coverUrl,
      title: recommendItemVideoItem.title,
      imageBottomBar: Padding(
        padding: const EdgeInsets.fromLTRB(5, 4, 5, 2),
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            Expanded(
              flex: 1,
              child: Row(
                children: [
                  const Icon(
                    Icons.ondemand_video,
                    size: 12,
                    color: Colors.white,
                  ),
                  Padding(
                    padding: const EdgeInsets.only(left: 3),
                    child: Text(
                      recommendItemVideoItem.playCount,
                      style: textStyle,
                    ),
                  ),
                ],
              ),
            ),
            Expanded(
              flex: 1,
              child: Row(
                children: [
                  const Icon(
                    Icons.menu_rounded,
                    size: 12,
                    color: Colors.white,
                  ),
                  Padding(
                    padding: const EdgeInsets.only(left: 3),
                    child: Text(
                      recommendItemVideoItem.danmuCount,
                      style: textStyle,
                    ),
                  ),
                ],
              ),
            ),
            Text(
              recommendItemVideoItem.videoDuration,
              style: textStyle,
            ),
          ],
        ),
      ),
      footer: Row(
        children: [
          recommendItemVideoItem.isPromotion
              ? Padding(
                  padding: const EdgeInsets.only(right: 2),
                  child: Icon(
                    Icons.rocket_launch,
                    size: 17,
                    color: Colors.pink.shade100,
                  ),
                )
              : const SizedBox(),
          recommendItemVideoItem.isVerticalScreen ||
                  recommendItemVideoItem.isHotLike
              ? Ink(
                  padding: const EdgeInsets.fromLTRB(3, 0, 3, 0),
                  decoration: BoxDecoration(
                    borderRadius: BorderRadius.circular(2),
                    color: const Color.fromARGB(255, 255, 232, 223),
                  ),
                  child: Text(
                    '${recommendItemVideoItem.isHotLike ? '${recommendItemVideoItem.likeCount}点赞' : ''}${recommendItemVideoItem.isVerticalScreen && recommendItemVideoItem.isHotLike ? ' | ' : ''}${recommendItemVideoItem.isVerticalScreen ? '竖屏' : ''}',
                    style: const TextStyle(
                      color: Color.fromARGB(255, 255, 98, 0),
                      fontSize: 11,
                    ),
                  ),
                )
              : const SizedBox(),
          recommendItemUPInfo?.isSubscribed ?? false
              ? const Row(
                  children: [
                    Icon(
                      Icons.check_circle_rounded,
                      color: Color.fromARGB(255, 255, 98, 0),
                      size: 14,
                    ),
                    Padding(
                      padding: EdgeInsets.only(left: 2),
                      child: Text(
                        '已关注',
                        style: TextStyle(
                          color: Color.fromARGB(255, 255, 98, 0),
                          fontSize: 12,
                        ),
                      ),
                    ),
                  ],
                )
              : const SizedBox(),
          Expanded(
            flex: 1,
            child: Padding(
              padding: const EdgeInsets.only(left: 4),
              child: Text(
                recommendItemUPInfo?.name ?? '',
                maxLines: 1,
                overflow: TextOverflow.ellipsis,
                style: const TextStyle(
                  color: Colors.black54,
                  fontSize: 12,
                ),
              ),
            ),
          )
        ],
      ),
    );
  }
}
